package cn.jinjimi.app.main.activity;

import android.content.Intent;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import cn.jinjimi.app.R;
import cn.jinjimi.app.controller.UserController;
import cn.jinjimi.app.controller.event.DataEvent;
import cn.jinjimi.app.controller.event.ThemeCurrentEvent;
import cn.jinjimi.app.entity.StandTheme;
import cn.jinjimi.app.main.extend.ToolBarCommonActivity;

import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

public class StandDetailActivity extends ToolBarCommonActivity {

    private RelativeLayout standPic;
    private RelativeLayout standModule;
    private RelativeLayout standBg;
    private TextView standModuleDesc;

    @Override
    protected void beforeInitView() {
        setContentView(R.layout.activity_modify_theme);
    }

    @Override
    protected void initial() {
        initView();
        initListener();
        initData();
    }

    protected void initView() {
        setTitle(R.string.site_diy);
        standPic = (RelativeLayout) findViewById(R.id.rl_site_pic);
        standModule = (RelativeLayout) findViewById(R.id.rl_theme_site);
        standBg = (RelativeLayout) findViewById(R.id.rl_modify_site_bg);
        standModuleDesc = (TextView) findViewById(R.id.tv_module_site);
    }

    protected void initListener() {
        standPic.setOnClickListener(this);
        standModule.setOnClickListener(this);
        standBg.setOnClickListener(this);
    }

    public void initData() {
        UserController.getCurrentTheme();
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onThemeCurrentEvent(ThemeCurrentEvent event) {
        if (isFinishing())
            return;
        switch (event.state) {
            case DataEvent.SUCC:
                StandTheme standTheme = event.data;
                if (standTheme.getTheme() != null) {
                    standModuleDesc.setText(standTheme.getTheme().getThemeName());
                }
                break;
        }
    }

    @Override
    public void onClick(View v) {
        super.onClick(v);
        switch (v.getId()) {
            case R.id.rl_theme_site:
                Intent intent = new Intent(this,ModifyStandThemeActivity.class);
                startActivity(intent);
                break;
        }
    }
}
